<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>老人管理-老人信息-新增老人</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/worker_assets/layertwo-assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/worker_assets/layertwo-assets/css/style.css" rel="stylesheet">
	<link href="/worker_assets/layertwo-assets/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="/plugins/SweetAlert/sweetalert.css" />
</head>
<body>
	<div class="container-fluid">
        <form method="post" enctype="multipart/form-data">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 员工管理</span><b class="fa fa-caret-right"></b><i>员工记录</i><b class="fa fa-caret-right"></b><i>编辑员工</i></div>
			</div>
			<div class="new-om-content">
				
				<div class="detail-content">
					<h3>基本信息</h3>
                    <div class="col-xs-3"><img src="<?=$tWData['photo']?>" id="img_view" name="photo"><button type="button" id="uploadBtn">上传照片</button></div>
                            <input type="hidden" name="id" value="<?=$pId?>" />
                            <input type="hidden" name="photo" value="<?=$tWData['photo']?>" />
                    <div style="display:none;"><input type="file" id="file" name="photo"/></div>
					<div class="col-xs-9">
						<div class="col-xs-12">
                        <div><label><b>*</b>姓名</label><input type="text" name="senior_name" value="<?=$tWData['name']?>"></div>
                        <div><label><b>*</b>性别</label><select name="sex"><option value="1" <?if($tWData['sex'] == 1)echo 'selected';?>>男</option><option value="2" <?if($tWData['sex'] == 2)echo 'selected';?>>女</option><option value="0" <?if($tWData['sex'] == 3)echo 'selected';?>>未知</option></select></div>
                        <div><label><b class="om-seds">*</b>院区</label><select name="department"><?foreach($tDIDatas as $tDIRow){?><option value="<?=$tDIRow['num']?>" <?if($tWData['department'] == $tDIRow['num'])echo 'selected';?>><?=$tDIRow['introduce']?></option><?}?></select></div>
                        <div class="sed"><label><b>*</b>职位</label><select name="worker_type"><?foreach($tRIDatas as $tRIRow){?><option value="<?=$tRIRow['num']?>"><?=$tRIRow['introduce']?></option><?}?></select></div>
                        <div id="longtext"><label><em>*</em>身份证号</label><input type="text" name="critcode" value="<?=$tWData['critcode']?>"></div>
                        <div><label><em>*</em>年龄</label><input type="text" name="age" value="<?=$tWData['age']?>"></div>
                        <div><label><em>*</em>出生年月</label><input type="text" name="birth_date" value="<?=$tWData['birthdate']?>" onclick="WdatePicker();"></div>
                        <div><label><em>*</em>联系电话</label><input type="text" name="phone" value="<?=$tWData['phone']?>"></div>
                        <div><label><em>*</em>上岗证</label><select name="work_licence"><option value="1" <?if($tWData['work_licence'] == 1)echo 'selected';?>>是</option><option value="2" <?if($tWData['work_licence'] == 2)echo 'selected';?>>否</option></select></div>
                        <div><label>民族</label><select name="nation"><?foreach($tNIDatas as $tNIRow){?><option value="<?=$tNIRow['num']?>" <?if($tWData['nation'] == $tNIRow['num'])echo 'selected';?>><?=$tNIRow['introduce']?></option><?}?></select></div>
                        <div><label>宗教</label><select name="religion"><?foreach($tReIDatas as $tReIRow){?><option value="<?=$tReIRow['num']?>" <?if($tWData['religion'] == $tReIRow['num'])echo 'selected';?>><?=$tReIRow['introduce']?></option><?}?></select></div>
                        <div><label><em>*</em>身体状况</label><select name="healthy_status"><option value="1" <?if($tWData['healthy_status'] == 1)echo 'selected';?>>优秀</option><option value="2" <?if($tWData['heaythy_status'] == 2)echo 'selected';?>>良好</option><option value="3" <?if($tWData['healthy_status'] == 3)echo 'selected';?>>合格</option><option value="4" <?if($tWData['healthy_status'] == 4)echo 'selected';?>>不合格</option></select></div>
                        <div><label><em>*</em>健康证</label><select name="healthy_licence"><option value="1" <?if($tWData['healthy_licence'] == 1)echo 'selected';?>>是</option><option value="2" <?if($tWData['healthy_licence'] == 2)echo 'selected';?>>否</option></select></div>
                        <div><label>婚姻情况</label><select name="married"><option value="1" <?if($tWData['married'] == 1)echo 'selected';?>>已婚</option><option value="2" <?if($tWData['married'] == 2)echo 'selected';?>>未婚</option><option value="3" <?if($tWData['married'] == 3)echo 'selected';?>>离异</option><option value="4" <?if($tWData['married'] == 4)echo 'selected';?>>丧偶</option></select></div>
                        <div><label>文化程度</label><select name="education_levels"><?foreach($tEIDatas as $tEIRow){?><option value="<?=$tEIRow['num']?>" <?if($tWData['education_levels'] == $tEIRow['num'])echo 'selected';?>><?=$tEIRow['introduce']?></option><?}?></select></div>

                        <div><label>籍贯</label><input type="text" name="native_place" value="<?=$tWData['native_place']?>"></div>

                        <div><label>家庭住址</label><input type="text" name="address" value="<?=$tWData['old_address']?>"></div>

						  </div>
					</div>
				</div>
                <h3>入职信息</h3>
                <div class="col-xs-12 entry-content">
                    <div class="col-xs-8">
                    <div><label>入职日期</label><input type="text" name="created" onclick="WdatePicker();" value="<?=$tWData['hiredate']?>"></div>
                    <div><label>入职渠道</label><select name="resource"><option value="1" <?if($tWData['resource'] == 1)echo 'selected';?>>内部推荐</option><option value="2" <?if($tWData['resource'] == 2)echo 'selected';?>>报纸</option><option value="3" <?if($tWData['resource'] == 3)echo 'selected';?>>网络</option><option value="4" <?if($tWData['resource'] == 4)echo 'selected';?>>电视</option><option value="5" <?if($tWData['resource'] == 5)echo 'selected';?>>其他</option></select></div>
                    <div><label>员工性质</label><select name="job_type"><option value="1" <?if($tWData['job_type'] == 1)echo 'selected';?>>临时员工</option><option value="2" <?if($tWData['job_type'] == 2)echo 'selected';?>>正式员工</option></select></div>
                    <div><label>试用期</label><input type="text" name="probation_period" value="<?=$tWData['probation_period']?>"></div>
                    <div><label>试用期薪资</label><input type="text" name="probation_fee" value="<?=$tWData['probation_fee']?>"></div>
                    <div><label>转正后薪资</label><input type="text" name="fee" <?=$tWData['fee']?>></div>
                    </div>
                    <div class="col-xs-4">
                    <label>备注</label><textarea rows='3' name="remarks" value="<?=$tWData['remarks']?>"></textarea></div>
                </div>
                <h3>工作经历<button type="button" id="add" onclick="addWorked();">添加</button></h3>
                <table class="table experience-content">
                 <thead>
                  <tr>
                    <th>公司名称</th>
                    <th>工作职位</th>
                    <th>工作内容</th>
                    <th>操作</th>
                  </tr>
              </thead>
             <tbody class="worked">
            <?foreach($tWHDatas as $tWHRow){?>
            <tr>
            <td><input type="text" name="workplace[]" value="<?=$tWHRow['work_place']?>"></td>
            <td><input type="text" name="worktype[]" value="<?=$tWHRow['work_type']?>"></td>
            <td><input type="text" name="descriptions[]" value="<?=$tWHRow['descriptions']?>"></td>
                <td><button class="delete">删除</button></td>
            </tr>
            <?}?>
             </tbody>
          </table>
          <div class="col-xs-12"><h3>家属信息(至少填写一位家属)<button type="button" onclick="addJiashu();">添加</button></h3></div>
                <table class='familyadd-content'>
                 <thead>
                  <tr>
                    <th><em>*</em><label>姓名</label></th>
                    <th><em>*</em><label>性别</label></th>
                    <th><em>*</em><label>关系</label></th>
                    <th><em>*</em><label>联系电话</label></th>
                    <th><em>*</em><label>身份证号</label></th>
                    <th><em>*</em><label>家庭住址</label></th>
                    <th><label>操作</label></th>
                  </tr>
              </thead>
             <tbody class="qinshu">
                <?foreach($tFDatas as $tFRow){?>
                  <tr>
                  <td><input type="text" name="js_name[]" value="<?=$tFRow['name']?>"></td>
                  <td><select name="js_sex[]"><option value="1" <?if($tFRow['sex'] == 1)echo 'selected';?>>男</option><option value="2" <?if($tFRow['sex'] == 2)echo 'selected';?>>女</option><option value="3" <?if($tFRow['sex'] == 3)echo 'selected';?>>未知</option></select></td>
                  <td><input type="text" name="js_relation[]" value="<?=$tFRow['relation']?>"></td>
                  <td><input type="text" name="js_phone[]" value="<?=$tFRow['phone']?>"></td>
                  <td><input type="text" name="js_critcode[]" value="<?=$tFRow['critcode']?>"></td>
                  <td><input type="text" name="js_address[]" value="<?=$tFRow['address']?>"></td>
                  <td><button type="button" onclick="cg_confirm_del('/admin_worker/delete?js_id=<?=$tFRow['id']?>','/admin_worker/edit?id=<?=$pId?>')">删除</button></td>
                  </tr>
                <?}?>
             </tbody>
          </table>
                   <div class="col-xs-12"><h3>领取物品<button type="button" onclick="addWupin();">添加</button></h3></div>
                <table class="table experience-content take-content">
                 <thead>
                  <tr>
                    <th>物品名称</th>
                    <th>领取时间</th>
                    <th>归还时间</th>
                    <th>备注</th>
                    <th>操作</th>
                  </tr>
              </thead>
             <tbody class="wupin">
            <?foreach($tGDatas as $tGRow){?>
            <tr>
            <td><input type="text" name="goods_name[]" value="<?=$tGRow['goodsname']?>"></td>
            <td><div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="updated"><input class="form-control" id="form-control" name="goods_starttime[]" size="16" id="takenow" value="<?=$tGRow['starttime']?>" type="text"></div></td>
            <td><div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="updated"><input class="form-control" id="form-control" name="goods_endtime[]" size="16" id="backnow" value="<?=$tGRow['endtime']?>" type="text"></div></td>
            <td><input type="text" name="goods_remarks[]" value="<?=$tGRow['remarks']?>"></td>                
            <td><button class="delete_wupin" type="button" onclick="cg_confirm_del('/admin_worker/delete?wp_id=<?=$tGRow['id']?>','/admin_worker/edit?id=<?=$pId?>')">删除</button></td></tr>
            <?}?>
             </tbody>
          </table>
          <div class="col-xs-12"><h3>护理病历</h3></div>
          <div class="tend-content">
              <div class="checklist">
              <div><input type="checkbox" name="cases[]" value="1" <?if(strpos($tWData['cases'],'1') !== false){echo 'checked';}?>><label>脑中风</label></div>
                        <div><input type="checkbox" name="cases[]" value="2"<?if(strpos($tWData['cases'],'2') !== false){echo 'checked';}?>><label>老年痴呆</label></div>
                        <div><input type="checkbox" name="cases[]" value="3"<?if(strpos($tWData['cases'],'3') !== false){echo 'checked';}?>><label>插尿管</label></div>
                        <div><input type="checkbox" name="cases[]" value="4"<?if(strpos($tWData['cases'],'4') !== false){echo 'checked';}?>><label>鼻伺</label></div>
                        <div><input type="checkbox" name="cases[]" value="5"<?if(strpos($tWData['cases'],'5') !== false){echo 'checked';}?>><label>骨折</label></div>
                        <div><input type="checkbox" name="cases[]" value="6"<?if(strpos($tWData['cases'],'6') !== false){echo 'checked';}?>><label>肿瘤</label></div>
                        <div><input type="checkbox" name="cases[]" value="7"<?if(strpos($tWData['cases'],'7') !== false){echo 'checked';}?>><label>腰间盘突出</label></div>
                        <div><input type="checkbox" name="cases[]" value="8"<?if(strpos($tWData['cases'],'8') !== false){echo 'checked';}?>><label>自理</label></div>
                        <div><input type="checkbox" name="cases[]" value="9"<?if(strpos($tWData['cases'],'9') !== false){echo 'checked';}?>><label>半自理</label></div>
                        <div><input type="checkbox" name="cases[]" value="10"<?if(strpos($tWData['cases'],'10') !== false){echo 'checked';}?>><label>不自理</label></div>
                        <div><input type="checkbox" name="cases[]" value="11"<?if(strpos($tWData['cases'],'11') !== false){echo 'checked';}?>><label>精神病</label></div>
                    </div>
          </div>
          <div class="col-xs-12"><h3>职业技能</h3></div>
          <div class="tend-content">
              <div class="checklist">
                        <div><input type="checkbox" name="skill[]" value="1"<?if(strpos($tWData['skill'],'1') !== false){echo 'checked';}?>><label>做饭</label></div>
                        <div><input type="checkbox" name="skill[]" value="2"<?if(strpos($tWData['skill'],'2') !== false){echo 'checked';}?>><label>给病人翻身</label></div>
                        <div><input type="checkbox" name="skill[]" value="3"<?if(strpos($tWData['skill'],'3') !== false){echo 'checked';}?>><label>拍痰</label></div>
                        <div><input type="checkbox" name="skill[]" value="4"<?if(strpos($tWData['skill'],'4') !== false){echo 'checked';}?>><label>吸氧</label></div>
                        <div><input type="checkbox" name="skill[]" value="5"<?if(strpos($tWData['skill'],'5') !== false){echo 'checked';}?>><label>测血压</label></div>
                        <div><input type="checkbox" name="skill[]" value="6"<?if(strpos($tWData['skill'],'6') !== false){echo 'checked';}?>><label>测血糖</label></div>
                        <div><input type="checkbox" name="skill[]" value="7"<?if(strpos($tWData['skill'],'7') !== false){echo 'checked';}?>><label>打胰岛素</label></div>
                        <div><input type="checkbox" name="skill[]" value="8"<?if(strpos($tWData['skill'],'8') !== false){echo 'checked';}?>><label>使用紫外线消毒灯</label></div>
                    </div>
          </div>
                    <div class="col-xs-12"><h3>身体情况</h3></div>
          <div class="tend-content">
              <div class="checklist">
                        <div><input type="checkbox" name="disease[]" value="1"<?if(strpos($tWData['disease'],'1') !== false){echo 'checked';}?>><label>皮肤病</label></div>
                        <div><input type="checkbox" name="disease[]" value="2"<?if(strpos($tWData['disease'],'2') !== false){echo 'checked';}?>><label>狐臭</label></div>
                        <div><input type="checkbox" name="disease[]" value="3"<?if(strpos($tWData['disease'],'3') !== false){echo 'checked';}?>><label>口腔病</label></div>
                        <div><input type="checkbox" name="disease[]" value="4"<?if(strpos($tWData['disease'],'4') !== false){echo 'checked';}?>><label>妇科病</label></div>
                        <div><input type="checkbox" name="disease[]" value="5"<?if(strpos($tWData['disease'],'5') !== false){echo 'checked';}?>><label>慢性病</label></div>
                    </div>
          </div>
           <div class="col-xs-12"><h3>添加账户</h3></div>
          <div class="tend-content">
              <div class="checklist">
                        <div class="department"><label>管理部门</label></div>
                        <?if(!empty($tADatas)){foreach($tDIDatas as $tDIRow){?>
                        <div><input type="checkbox" name="adminpartemnt[]" value="<?=$tDIRow['num']?>" <?if(strpos($tADatas['department'],$tDIRow['num']) !== false){echo 'checked';}?>><label class="introduce"><?=$tDIRow['introduce']?></label></div>
                        <?}}?>
                        <div class="col-xs-12 input-text"><span>账号</span><input type="text" name="admin_username" value="<?=$tADatas['name']?>" disabled></div>
                        <div class="col-xs-12 input-text"><span>密码</span><input type="password" name="admin_passwd" value="<?=$tADatas['passwd']?>"></div>
                    </div>
          </div>
         <div class="col-xs-12 last"><h3>扫描件信息</h3></div>
                   <div class="col-xs-12 scan-content">
                    <?foreach($tScDatas as $tScRow){?>
                    <div class="scan-img"><img src="<?=$tScRow['imgurl']?>"><span onclick="cg_confirm_del('/admin_worker/delete?sc_id=<?=$tScRow['id']?>','/admin_worker/edit?id=<?=$pId?>')" name="oldimg" data="<?=$tScRow['id']?>"></span></div>
                    <?}?>
                       <div class="scan-field"><input type="file" name="file_img[]" multiple="multiple" id="file_img"/></div>
                   </div>
                           
            </div>

            <div class="footer"><div><button type="button" id="save">保存</button><button type="button" onclick="location.href='/admin_worker'">取消</button></div>
                </div>
            </div> 
            </form>
    </div>
      <script type="text/javascript" src="/worker_assets/js/jquery.min.js"></script>
<script src="/plugins/bootstrap/js/bootstrap.min.js"></script>
<script src="/plugins/SweetAlert/sweetalert.min.js"></script><!--alert插件-->
<script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
<script src="/js/jquery.form.js"></script><!--form表单插件-->
<script>
var upload = function(){};

upload.prototype.input_file_click = function(filename){
    var fileObj = $('input[name="'+filename+'"]'); 
    fileObj.bind('change',function(){
        var file = document.getElementById(filename.replace("[]","")).files;  
        for(var i in file){
            //将文件以Data URL形式读入页面  
            var reader = new FileReader();  
            reader.readAsDataURL(file[i]);  
            reader.onload=function(e){  
                $('.scan-field').before('<div class="scan-img"><img src="'+e.target.result+'"><span onclick="$(this).parent().remove();"></span></div>');
            };
        }
        fileObj.unbind('change');
    });
    fileObj.click();
}
var up = new upload();
$(function(){
    $('input[name="file_img[]"]').click(function(){
        up.input_file_click('file_img[]');
    });
});
$('#uploadBtn').click(function(){
    $('#file').click();
});
var result = document.getElementById('img_view');
var input = document.getElementById('file');
if(typeof FileReader==='undefined'){
    result.innerHTML = '抱歉，你的浏览器不支持 FileReader';
    input.setAttribute('disabled','disabled');
}else{
    input.addEventListener('change',readFile,false);
}
function readFile(){
    var file = this.files[0];
    if(!/image\/\w+/.test(file.type)){
        alert('文件必须为图片');
        return false;
    }
    var reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = function(e){
        $('img[name="photo"]').attr('src',this.result);
    }
}
function addWorked(){
   $('.worked').append('<tr><td><input type="text" name="workplace[]"></td><td><input type="text" name="worktype[]"></td><td><input type="text" name="descriptions[]"></td><td><button class="delete">删除</button></td></tr>');
    $('.delete').click(function(){
        $(this).parent().parent().remove();
    });
}
function addWupin(){
        $('.wupin').append('<tr><td><input type="text" name="goods_name[]"></td><td><div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="updated"><input class="form-control" id="form-control" name="goods_starttime[]" size="16" id="takenow" value="" type="text"></div></td><td><div class="input-group date form_date" data-date="" data-date-format="yyyy-mm-dd" data-link-field="updated"><input class="form-control" id="form-control" name="goods_endtime[]" size="16" id="backnow" value="" type="text"></div></td><td><input type="text" name="remarks" value=""></td><td><button class="delete_wupin">删除</button></td></tr>');
    $('.delete_wupin').click(function(){
        $(this).parent().parent().remove();
    });
}
$('select[name="worker_type"]').on('change',function(){
    $('#patient_cases').css('display','none');
    $('#professional_skill').css('display','none');
    if($(this).val() == 7){
        $('#patient_cases').css('display','block');
        $('#professional_skill').css('display','block');
    }
    var role = $(this).val();
    var department_id = $('select[name="department"]').val();
    $.post('/admin_worker/add',{role:role,department_id:department_id},function(obj){
        if(obj.status == 1){
           var data = obj.data; 
           $('input[name="admindepartment[]"]').remove();
            $('.introduce').remove();
           for(var i in data){
                $('.department').after('<div><input type="checkbox" name="admindepartment[]" value="'+data[i].num+'"><label>'+data[i].introduce+'</label></div>');
           }
        }
    });
});
$('select[name="department"]').on('change',function(){
    var department_id = $(this).val();
    var role = $('select[name="worker_type"]').val();
    $.post('/admin_worker/add',{role:role,department_id:department_id},function(obj){
        if(obj.status == 1){
           var data = obj.data; 
           $('input[name="admindepartment[]"]').remove();
            $('.introduce').remove();
           for(var i in data){
                $('.department').after('<div><input type="checkbox" name="admindepartment[]" value="'+data[i].num+'"><label>'+data[i].introduce+'</label></div>');
           
           }
        }
    });
});
function addJiashu(){
    $('.qinshu').append('<tr><td><input type="text" name="js_name[]"></td><td><select name="js_sex[]"><option value="1">男</option><option value="2">女</option><option value="3">未知</option></select></td><td><input type="text" name="js_relation[]"></td><td><input type="text" name="js_phone[]"></td><td><input type="text" name="js_critcode[]"></td><td><input type="text" name="js_address[]"></td><td><button type="button" onclick="$(this).parent().parent().remove();">删除</button></td></tr>');
}
$(function(){
//提交
    var options={
        beforeSubmit : showRequest,    // 提交前的回调函数
        success : showResponse,    // 提交后的回调函数
        dataType : "json",    // html（默认）、xml、script、json接受服务器端返回的类型
        timeout : 3000    // 限制请求的时间，当请求大于3秒后，跳出请求
    }
    function showRequest(formData, jqForm, options){
        return true;
    }
    function showResponse(responseText,statusText){
            cg_alert_edit(responseText,'/admin_worker','/admin_worker/edit?id=<?=$pId?>');
    }
    $('#save').click(function(){
        var r=document.getElementsByName("admindepartment[]"); 
        var department_id = '';
        for(var i=0;i<r.length;i++){
            if(r[i].checked){
                department_id += r[i].value+',';
            }
        }     
        $('input[name="senior_name"]').after('<input type="hidden" name="department_id" value="'+department_id+'" />');
        $('form').ajaxSubmit(options);
    });
    $('#search').click(function(){
        $('form').submit();
    });


});
function cg_alert_edit(obj,list_url,edit_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续修改',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = edit_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_confirm_del(del_url,jump_url){
    swal({
            title: '您确定要删除吗？',
            text:'删除之后不能恢复',
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText:'确定',
            closeOnConfirm: false,
            cancelButtonText:'取消'
        },
        function(isConfirm){
            if(isConfirm){
                window.obj = '';
                $.ajax({
                    url: del_url,
                    dataType: "json",
                    async:false,
                    success: function (obj) {
                        window.obj = obj;
                    }
                });

                if(window.obj.status == 1){
                    swal({title:"删除成功!", type:"success"},function(){
                        location.href = jump_url;
                    });
                }else{
                    swal({title:window.obj.msg, type:"error"});
                }
            }
        });
}

</script>
</body>
</html>
